package saveservice

import (
	"gopkg.in/olivere/elastic.v5"
	"goruntimeDistributionCrawler/engine"
)

type ItemSaveService struct {
	Client *elastic.Client
	Index string
}

func (service ItemSaveService) Save(
	item engine.Item, result *string) error {
	err:=SaveProfileData(item,service.Client,service.Index)

	//id,err:=service.Client.Index().
	//	Index(service.Index).
	//	Type(item.Type).
	//	BodyJson(item.Payload).
	//	Id(item.Id).
	//	Do(context.Background())
	//
	//fmt.Println(id.Id)

	if err ==nil{
		*result="ok"
	}
	return err

}
